package com.lzhl.buildjar.ui.support;

import javax.swing.*;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 李柱良(@柱子的日月)
 * @date 2016/2/22
 */
public class Cmd {
    public static final Cmd CATEGORY_ADD = new Cmd("categoryAdd", "新建", "ctrl shift N", "categoryAdd.png");
    public static final Cmd SCHEME_ADD = new Cmd("schemeAdd", "新建", "ctrl N", "schemeAdd.png");
    public static final Cmd SCHEME_SAVE = new Cmd("schemeSave", "保存", "ctrl S", "save.png");
    public static final Cmd SCHEME_REFRESH = new Cmd("schemeRefresh", "刷新", "F5", "refresh.png");
    public static final Cmd SCHEME_DEL = new Cmd("schemeDel", "删除", "ctrl D", "delete.png");
    public static final Cmd SHOW_ADV = new Cmd("showAdv", "高级选项", "ctrl O", "showAdv.png");
    public static final Cmd SETTING = new Cmd("setting", "设置", "ctrl alt S", "setting.png");
    public static final Cmd TOOLS = new Cmd("tools", "工具", "ctrl T", "tools.png");

    public static final Cmd LINE_UP = new Cmd("lineUp", "上移", "alt UP", "toolLineUp.png");
    public static final Cmd LINE_DOWN = new Cmd("lineDown", "下移", "alt DOWN", "toolLineDown.png");
    public static final Cmd LINE_TOP = new Cmd("lineTop", "至顶", "ctrl alt UP", "toolLineTop.png");
    public static final Cmd LINE_BOTTOM = new Cmd("lineBottom", "至底", "ctrl alt DOWN", "toolLineBottom.png");
    public static final Cmd LINE_ADD = new Cmd("lineAdd", "添加行", "alt N", "toolLineAdd.png");
    public static final Cmd LINE_DEL = new Cmd("lineDel", "删除行", "alt D", "toolLineDel.png");
    public static final Cmd LINE_CLEAR = new Cmd("lineClear", "全部删除", "alt DELETE", "lineClear.png");

    public static final Cmd ADD_INNER = new Cmd("addInner", "添加内部类", "ctrl I", "addInner.png");
    public static final Cmd DEL_INNER = new Cmd("delInner", "删除内部类", "alt I", "delInner.png");
    public static final Cmd CLEAR_REPEAT = new Cmd("clearRepeat", "消除重复项", "alt R", "clearRepeat.png");
    public static final Cmd CHECK_SCHEME = new Cmd("schemeCheck", "检查", "ctrl K", "check.png");
    public static final Cmd BUILD_JAR = new Cmd("buildJar", "打包", "ctrl B", "build.png");

    public static final Cmd HELP = new Cmd("help", "帮助", "F1", "help.png");
    public static final Cmd ABOUT = new Cmd("about", "关于", "", "about.png");
    public static final Cmd LOGOUT = new Cmd("logout", "退出", "", "logout.png");

    public static final Cmd CATEGORY_FOCUS = new Cmd("categoryFocus", "F3");
    public static final Cmd SCHEME_FOCUS = new Cmd("schemeFocus", "F4");
    public static final Cmd LINE_BROWSER = new Cmd("browser");
    public static final Cmd LINE_LOCATION = new Cmd("location");
    public static final Cmd SCHEME_OPEN = new Cmd("schemeOpen");
    public static final Cmd SCHEME_SEND = new Cmd("schemeSend");
    public static final Cmd IS_EDITED = new Cmd("isEdited");
    public static final Cmd AUTO_FILL = new Cmd("autoFill");
    public static final Cmd TO_JAVA = new Cmd("toJava");
    public static final Cmd TO_CLASS = new Cmd("toClass");

    private String code;
    private String name;
    private String shortcutkey;
    private String icon;

    public Cmd(String code) {
        this.code = code;
    }

    public Cmd(String code, String shortcutkey) {
        this.code = code;
        this.shortcutkey = shortcutkey;
    }

    public Cmd(String code, String name, String shortcutkey, String icon) {
        this.code = code;
        this.name = name;
        this.shortcutkey = shortcutkey;
        this.icon = icon;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getShortcutkey() {
        return shortcutkey;
    }

    public void setShortcutkey(String shortcutkey) {
        this.shortcutkey = shortcutkey;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof Cmd) {
            return this.code.equals(((Cmd)obj).getCode());
        }
        return false;
    }

    public Cmd copy() {
        Cmd cmd = new Cmd(this.code, this.name, this.shortcutkey, this.icon);
        return cmd;
    }

}
